package Born.utils.Effects
{
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.filters.DisplacementMapFilter;
	import flash.geom.Point;

	public class WaterFx
	{
		private static var clipName						:MovieClip;
		private static var myBitmap						:BitmapData;
		private static var mpoint						:Point;
		private static var myDispl						:DisplacementMapFilter;
		private static var i							:uint;
		private static var myFilters					:Array;
		private static var offset						:Array;
		
		public static function add(_clipName:MovieClip):void
		{
			trace("********* WaterFx not work yet *********");
			
			clipName = _clipName;
			
			myBitmap = new BitmapData(clipName.width, clipName.height, false, 0);
			mpoint = new Point (0, 0);
			myDispl = new DisplacementMapFilter (myBitmap, mpoint, 1, 2, 10, 50);
			
			myFilters = new Array();
			myFilters.push(myDispl);
			clipName.filters = myFilters;
			clipName.addEventListener(Event.ENTER_FRAME, RenderFilter);
		}
		
		private static function RenderFilter(e:Event):void
		{
			offset = new Array();
			offset[1] = new Object();
			offset[1].x = i;
			offset[1].y = i/3;
			
			var filterList:Array = myFilters;
			myBitmap.perlinNoise(45,15,2,50,true,true,7,true,offset);
			filterList.mapBitmap = myBitmap;
			clipName.filters = myFilters;
			i++;
		}
		
	} /** End of Class **/
	
} /** End of Package **/